import type { RouteRecordRaw } from "vue-router";
import { defaultRoutes } from "@/router/routes";

/**
 * staticRouter(静态路由)
 */
export const staticRouter: RouteRecordRaw[] = [
  {
    path: "/account",
    name: "AccountView",
    meta: {
      title: "账户",
      open: true,
      hidden: false,
      isLeaf: true,
      icon: "",
    },
    component: defaultRoutes.get("AccountView"),
    children: [
      {
        path: "/account/login",
        name: "LoginView",
        meta: {
          title: "登录页",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("LoginView"),
      },
      {
        path: "/account/register",
        name: "RegisterView",
        meta: {
          title: "注册页",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("RegisterView"),
      },
      {
        path: "/account/forget",
        name: "ForgetView",
        meta: {
          title: "忘记密码",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("ForgetView"),
      },
      {
        path: "/account/lock",
        name: "LockView",
        meta: {
          title: "锁定",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("LockView"),
      },
    ],
  },
];

/**
 * errorRouter(错误页面路由)
 */
export const errorRouter = [
  {
    path: "/error",
    name: "error",
    meta: {
      title: "错误页",
      open: true,
      hidden: false,
      isLeaf: true,
      icon: "",
    },
    redirect: "/error/404",
    component: defaultRoutes.get("ErrorIndex"),
    children: [
      {
        path: "/error/403",
        name: "403",
        meta: {
          title: "未授权",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("Error403"),
      },
      {
        path: "/error/404",
        name: "404",
        meta: {
          title: "页面未找到",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("Error404"),
      },
      {
        path: "/error/500",
        name: "500",
        meta: {
          title: "系统错误",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("Error500"),
      },
      {
        path: "/error/developing",
        name: "developing",
        meta: {
          title: "开发中",
          open: true,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component: defaultRoutes.get("ErrorDeveloping"),
      },
    ],
  },
];

/**
 * notFoundRouter(找不到路由)
 */
export const notFoundRouter = {
  path: "/:pathMatch(.*)*",
  name: "notFound",
  meta: {
    title: "通配页",
    open: true,
    hidden: false,
    isLeaf: true,
    icon: "",
  },
  redirect: { name: "404" },
};

/**
 * asyncRouter(异步路由)
 */
export const asyncRouter: RouteRecordRaw[] = [
  {
    path: "/",
    name: "index",
    meta: {
      title: "后台",
      open: false,
      hidden: false,
      isLeaf: true,
      icon: "",
    },
    redirect: "/home",
    component: defaultRoutes.get("LContainer"),
    children: [
      {
        path: "/home",
        name: "home",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("HomeView") || defaultRoutes.get("ErrorDeveloping"),
      },
      {
        path: "/search",
        name: "search",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("SearchView") ||
          defaultRoutes.get("ErrorDeveloping"),
      },
      {
        path: "/chart",
        name: "chart",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        redirect: "/chart/list",
        component:
          defaultRoutes.get("LMain") || defaultRoutes.get("ErrorDeveloping"),
        children: [
          {
            path: "/chart/list",
            name: "chartList",
            meta: {
              title: "后台详情列表",
              open: false,
              hidden: false,
              isLeaf: true,
              icon: "",
            },
            component:
              defaultRoutes.get("AboutView") ||
              defaultRoutes.get("ErrorDeveloping"),
          },
          {
            path: "/chart/:id",
            name: "chartView",
            meta: {
              title: "后台详情",
              open: false,
              hidden: false,
              isLeaf: true,
              icon: "",
            },
            component:
              defaultRoutes.get("AboutDeatilView") ||
              defaultRoutes.get("ErrorDeveloping"),
          },
        ],
      },
      {
        path: "/cp",
        name: "cp",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("CpView") || defaultRoutes.get("ErrorDeveloping"),
      },
      {
        path: "/buy",
        name: "buy",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("BuyView") || defaultRoutes.get("ErrorDeveloping"),
      },
      {
        path: "/setting",
        name: "setting",
        meta: {
          title: "后台",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("VideoView") ||
          defaultRoutes.get("ErrorDeveloping"),
      },
      {
        path: "/video/:id",
        name: "videoDetails",
        meta: {
          title: "播放",
          open: false,
          hidden: false,
          isLeaf: true,
          icon: "",
        },
        component:
          defaultRoutes.get("VideoView") ||
          defaultRoutes.get("ErrorDeveloping"),
      },
    ],
  },
];
